package br.edu.ufcg.ga.stopcondition;

public class HybridStopCondition extends StopCondition {

	private MaxGenerationsStopCondition mgsc;

	private MaxBestFitnessRepetitionStopCondition mbfrsc;

	public HybridStopCondition(int maxGenerations, int maxRepetitionOfBestFitness) {
		this.mgsc = new MaxGenerationsStopCondition(maxGenerations);
		this.mbfrsc = new MaxBestFitnessRepetitionStopCondition(maxRepetitionOfBestFitness);

		this.mgsc.setState(this.s);
		this.mbfrsc.setState(this.s);
	}

	@Override
	protected boolean workIsDone(int cGeneration, double cBestFitness) {
		return this.mgsc.workIsDone(cGeneration, cBestFitness) || this.mbfrsc.workIsDone(cGeneration, cBestFitness);
	}

}